<template>
  <div class="demo">
    <h3 class="title">学生姓名：{{ name }}</h3>
    <h3 class="atguigu">学生性别：{{ sex }}</h3>
    <button @click="sendStudentName">把学生名给school组件</button>
  </div>
</template>

<script>
export default {
  name: 'Student',
  data() {
    return {
      name: '张三',
      sex: '男'
    }
  },
  methods: {
    sendStudentName() {
      //触发当前实例上的事件
      this.$bus.$emit('hello',this.name)
    }
  },
}
</script>

<style lang="less" scoped>
.demo {
  background-color: pink;

  .atguigu {
    font-size: 40px;
  }
}
</style>
